<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!-- 核心标签是最常用的JSTL标签 -->
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><!-- 包含一系列标准函数,大部分 是通用的字符串处理函数 -->
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><!-- 格式化并输出文本、日期、时间、数字 -->
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
<head>
<title>3D捕鱼房间 -- </title>
<base href="<%=basePath%>" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="css/MyCSS.css">
<!-- 适应所有设备 -->
<style type="text/css">
html, body {
	height: 100%;
	margin: 0;
	padding: 0;
}

.layui-form-label {
	width: 150px;
	font-size: 18px;
	text-align: left;
	padding-right: 0px;
	margin-right: 0px;
}

.layui-input-block {
	
}

.layui-nav {
	width: 40%;
	padding: 0px;
}

.layui-nav .layui-nav-item {
	width: 20%;
}

.layui-tab {
	height: 600px;
	overflow-y: auto;
	margin: 0px;
}
</style>
</head>
<body>
<br/>
			<div class="layui-tab layui-tab-card" lay-filter="Fish_tabs" style="height:100%;">
				<ul class="layui-tab-title">
					<li class="layui-this" lay-id="1">初级房</li>
					<li lay-id="2">中级房</li>
					<li lay-id="3">高级房 </li>
				</ul>
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show">
						<%@ include file="../room/shz_public_tabs.jsp"%>
					</div>
				</div>
			</div>
			<br />
			
    <script type="text/html" id="IsBusinessman">
            {{#  if(d.IsBusinessman === false){ }}
                <span class="layui-badge layui-bg-green">玩家</span>
            {{#  } else if(d.IsBusinessman === true){ }}
                <span class="layui-badge layui-bg-blue">会长</span>
            {{#  } }}
        </script>
		
		<script type="text/html" id="playertable">
			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            {{#  if(d.IsBlocked == 0){ }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit">未锁定</a>
              {{#  } else { }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit2">已锁定</a>
              {{#  } }}
        </script>
        
        <script type="text/html" id="DifficultAllLevel">
            {{# if(d.AllWaterLine < d.WaterLineLimit[0]){ }}
                <span>很难</span>
            {{# }else if(d.AllWaterLine >= d.WaterLineLimit[0] && d.AllWaterLine < d.WaterLineLimit[1]){ }}
                <span>难</span>
            {{# }else if(d.AllWaterLine >= d.WaterLineLimit[1] && d.AllWaterLine < d.WaterLineLimit[2]){  }}
                <span>默认</span>
            {{# }else if(d.AllWaterLine >= d.WaterLineLimit[2] && d.AllWaterLine < d.WaterLineLimit[3]){  }} 
                <span>容易</span>
            {{# }else if(d.AllWaterLine >= d.WaterLineLimit[3]){ }}
                <span>极易</span>
            {{# } }}
        </script>
        
        <script type="text/html" id="RealGain">
            {{#  d.RealGain = d.TotalCurrencyWin - d.TotalCurrencyLost }}
                 <span>{{ d.RealGain }}</span>
            {{#  }}
         </script>

	<script src="js/jQuery-2.2.0.min.js"></script>
	<script src="layui/layui.js"></script>
    <script src="js/common/monitor_back.js"></script>

	<script type="text/javascript">
        layui.use(['layer','element','table','form'],function(){
        	var layer = layui.layer
        	    ,element = layui.element
        	    ,table = layui.table
        	    ,form = layui.form;
        	layer.config({
				extend: 'MySkin/style.css'
			});
        	
        table.render({
        	elem:'#difficult',
        	url:'room/shz/table',
        	method:'post',
        	totalRow:true,
        	page:false,
        	cellMinWidth:80,
        	id:'Alltable2',
        	where:{
        		ConfigId:$('#Fish_Tabindex').val()
        	},
        	cols: [[
        		{field : 'AllWaterLine',title : '水位',align : 'center'},
        		{field : 'AllFeeGrab',title : '平台收益',align : 'center'},
        		{field : 'WaterLineLimit',title : '水位界限',align : 'center',hide:true},
        		{field : 'DifficultAllLevel',title : '当前难度级别',align : 'center',templet:'#DifficultAllLevel'},
        		{title : '操作',fixed : 'right',align : 'center',toolbar : '#tool'}
        	]],
        	response:{
        		statusCode : 200
        	},
        	parseData: function(res){
        		return{
        			"code":res.status,
        			"msg":res.message,
        			"count":res.count,
        			"data":res.data
        		};
        	}
        });
        
        table.render({
			elem: '#onlineTable',
			url: 'pa/onlinelist',
			method: 'post',
			title: '玩家资源变化',
			totalRow: true,
			autoSort: false,
			cellMinWidth: 50, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
			id: 'AllTable',
			request: {
				pageName: 'PageIndex',
				limitName: 'PageCount'
			},
			where: {
				Room : $('#Fish_Tabindex').val() == 1?"水浒传-房间1":$('#Fish_Tabindex').val() == 2?"水浒传-房间2":"水浒传-房间3",
				Businessman : 0
			},
			cols: [[
				{field: 'Id',title: 'ID'}, 
				{field: 'Nickname',title: '昵称'}, 
				{field:'IsBusinessman',title:'玩家/会长',templet:'#IsBusinessman',event:'setSign'},
				{field: 'LocationRoom',title: '所在游戏【房间】',templet:'#LocationRoom'},
				{field: 'LocationPlatform',title: '所在游戏【房间】台子',hide:true},
				{field: 'Currency',title: '携带金币',sort: true},
				{field: 'BankCurrency',title: '金库金币',sort: true}, 
				{field: 'TotalCurrencyLost',title: '总输',sort: true,hide:true}, 
				{field: 'TotalCurrencyWin',title: '总赢',sort: true,hide:true},
				{field: 'RealGain',title: '总输赢',sort: true,templet:'#RealGain'},
				{field:'LastLoginTime',title:'最后登陆时间'},
				{field:'LastLoginIp',title:'最后登录IP'},
				{field: 'IsBlocked',title: '封禁',hide:true}, 
				{field: 'CheatMode',title: '调整(数量/类型)',hide:true},
				{field:'Phone',title:'绑定的手机号码',hide:true},
				{field:'BankPassword',title:'金库密码',hide:true},
				{field:'Diamond',title:'钻石',hide:true},
				{field:'ItemLock',title:'锁定',hide:true},
				{field:'ItemFreeze',title:'冰冻',hide:true},
				{field:'ItemSummon',title:'召唤',hide:true},
				{field:'ItemWild',title:'狂暴',hide:true},
				{field:'ItemShadow',title:'分身',hide:true},
				{field:'Item10',title:'防水木料',hide:true},
				{field:'Item11',title:'精炼矿石',hide:true},
				{field:'Item12',title:'海妖外壳',hide:true},
				{field:'Item13',title:'潮汐精粹',hide:true},
				{field:'Item14',title:'深海魔晶',hide:true},
				{field:'ItemMultipleHit',title:'倍击',hide:true},
				{field:'Integral',title:'积分',hide:true},
				{field:'ItemTicket',title:'奖券',hide:true},
			    {title: '操作',fixed: 'right',width: 200,toolbar: '#playertable'}
				]],
			page: true, //分页
			response: {
				statusCode: 200
				//重新规定成功的状态码为 200，table 组件默认为 0
			},
			parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
				for (var i = 0; i < res.data.length; i++) {
					for (var key in res.data[i]) {
						if (res.data[i][key] == null) {
							res.data[i][key] == '无';
						}
					}
				}
				return {
					"code": res.status, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.count, //解析数据长度
					"data": res.data //解析数据列表
					//解析数据列表
				};
			}
		});
        
        
        
        setInterval(function(){
          	table.reload('Alltable2', {
          		page : {cuur : 1},
          		where:{ConfigId:$('#Fish_Tabindex').val()}
          	});
          	table.reload('AllTable', {
          		where: {
					Room : $('#Fish_Tabindex').val() == 1?"水浒传-房间1":$('#Fish_Tabindex').val() == 2?"水浒传-房间2":"水浒传-房间3",
					Businessman : 0
				}
          	});
          },60000);
        
      //在线玩家
	    //监听行工具事件
		  table.on('tool(onlineTable)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
              if (history.state == null){
                  pushHistory();
              }
		    var data = obj.data //获得当前行数据
		    ,layEvent = obj.event; //获得 lay-event 对应的值
		    if(layEvent === 'detail'){
		    	var id = data.Id;
		    	var Nickname = data.Nickname;
				var RegisterIp = data.RegisterIp;
				var LastLoginIp = data.LastLoginIp;
				var Diamond = data.Diamond;
		    	var ItemLock = data.ItemLock;
				var ItemFreeze = data.ItemFreeze;
				var ItemSummon = data.ItemSummon;
				var ItemWild = data.ItemWild;
		    	var ItemShadow = data.ItemShadow;
				var Item10 = data.Item10;
				var Item11 = data.Item11;
				var Item12 = data.Item12;
		    	var Item13 = data.Item13;
				var Item14 = data.Item14;
				var ItemMultipleHit = data.ItemMultipleHit;
				var Integral = data.Integral;
				var ItemTicket = data.ItemTicket;
				var ItemWarhead1 = data.ItemWarhead1;
		    	var ItemWarhead2 = data.ItemWarhead2;
				var ItemWarhead3 = data.ItemWarhead3;
				var ItemWarhead4 = data.ItemWarhead4;
				var Phone = data.Phone;
				var BankPassword = data.BankPassword;
				var index = layer.open({
					type: 2,
					shadeClose: true,
					shade: 0.5,
					area: ['100%', '100%'],
					title: "查看玩家信息",
					skin: 'layer-ext-yourskin',
					content: '<%=basePath%>pa/detail/playRecords',
					success: function(layero, index) {
						var body = layer.getChildFrame("body", index);
						// 取到弹出层里的元素，并把编辑的内容放进去
						body.find(".UserId").html(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
						body.find(".zlastLoginIp").html(LastLoginIp);
						body.find("#nickname").html(Nickname);
						body.find("#RegisterIp").html(RegisterIp);
						body.find(".Diamond").html(Diamond);
						body.find("#ItemLock").html(ItemLock);
						body.find("#ItemFreeze").html(ItemFreeze);
						body.find("#ItemSummon").html(ItemSummon);
						body.find("#ItemWild").html(ItemWild);
						body.find("#ItemShadow").html(ItemShadow);
						body.find("#Item10").html(Item10);
						body.find("#Item11").html(Item11);
						body.find("#Item12").html(Item12);
						body.find("#Item13").html(Item13);
						body.find("#Item14").html(Item14);
						body.find("#ItemMultipleHit").html(ItemMultipleHit);
						body.find("#Integral").html(Integral);
						body.find("#ItemTicket").html(ItemTicket);
						body.find("#ItemWarhead1").html(ItemWarhead1);
						body.find("#ItemWarhead2").html(ItemWarhead2);
						body.find("#ItemWarhead3").html(ItemWarhead3);
						body.find("#ItemWarhead4").html(ItemWarhead4);
						body.find("#Phone").html(Phone);
						body.find("#BankPassword").html(BankPassword);
					},
                    cancel:function () {
                        window.history.back();
                    }
				});
		    } else if(layEvent === 'adjust'){
		    	var id = data.Id;
				var name = data.Nickname;
				var currency = data.Currency;
				var index = layer.open({
					type: 2,
					shadeClose: true,
					shade: 0.5,
					area: ['1500px', '800px'],
					title: '调整玩家上下分',
					skin: 'layer-ext-yourskin',
					content: '<%=basePath%>pa/detail/playAdjustment',
					success: function(layero, index) {
						var body = layer.getChildFrame("body", index); //绑定父子页面
						body.find(".zid").val(id);
						body.find(".zname").val(name);
						body.find("#Currency").val(currency);
					},
                    cancel:function () {
                        window.history.back();
                    }
		      });
		    } else if(layEvent === 'edit'){
		        var id = data.Id;
				var name = data.Nickname;
				var index = layer.open({
					type: 2,
					shadeClose: true,
					shade: 0.5,
					area: ['100%', '100%'],
					title: '锁定玩家',
					skin: 'layer-ext-yourskin',
					content: '<%=basePath%>pa/detail/playBlock',
					success: function(layero, index) {
						var body = layer.getChildFrame("body", index);
						// 取到弹出层里的元素，并把编辑的内容放进去
						body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
						body.find(".zname").val(name);
					},
                    cancel:function () {
                        window.history.back();
                    }
				});
		    }else if(layEvent === 'edit2'){
		    	var id = data.Id;
				var name = data.Nickname;
				var index = layer.open({
					type: 2,
					shadeClose: true,
					shade: 0.5,
					area: ['100%', '100%'],
					title: '解锁玩家',
					skin: 'layer-ext-yourskin',
					content: '<%=basePath%>pa/detail/playUnBlock',
					success: function(layero, index) {
						var body = layer.getChildFrame("body", index); //绑定父子页面
						// 取到弹出层里的元素，并把编辑的内容放进去
						body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
						body.find(".zname").val(name);
						//parent.layer.close(index);//关闭子页面
					},
                    cancel:function () {
                        window.history.back();
                    }
				});
		    }else if(layEvent === 'setSign'){
		    	var id = data.Id;
		    	var index = layer.open({
					type: 2,
					shadeClose: true,
					shade: 0.5,
					area: ['500px', '200px'],
					title: '设置会长',
					skin: 'layer-ext-yourskin',
					content: '<%=basePath%>pa/detail/setBusinessman',
					success: function(layero, index) {
						var body = layer.getChildFrame("body", index); //绑定父子页面
						body.find(".zid").val(id); 
					},
                    cancel:function () {
                        window.history.back();
                    }
				});
		    }
		  });	
		
        
        
        table.on('tool(difficult)',function(obj){
            if (history.state == null){
                pushHistory();
            }
        	var str = '<div class="layui-inline" style="margin-left:35%;margin-top:5%;">' +
			'<label"><strong>难度选择</strong></label>' +
			'<div class="layui-input-inline">' +
			'<select name="select_difficult" id="select_difficult" lay-filter="select_difficult" style="width:100px;background:#009688;color:white;">' +
			'</select>' +
			'</div>' +
			'</div>';
        	var data = obj.data;
        	if (obj.event == 'pump') {
				var ServerId = $('#ServerId option:selected').val();
				var ConfigId = $('#Fish_Tabindex').val();
				var PlatformId = -1;
				layer.confirm('<div style="text-align:center;margin:0 auto;"><h2>修改值<br/><span style="color:red;">大于0放水</span><br/><sapn style="color:red;">小于0抽水</span><br/><sapn style="color:red;">水位或彩金不能填0</span><br/></h2></div>',{
					btn:['我已了解','退出']//按钮
				},function(index){
	    			var index = layer.open({
						type: 2,
						shadeClose: true,
						shade: 0.5,
						area: ['1200px', '400px'],
						title: '修改水位|彩金池',
						skin: 'layer-ext-yourskin',
						content: '<%=basePath%>room/toSetRoom',
						success: function(layero,index,resp) {
							var body = layer.getChildFrame("body",index);
							body.find(".ServerId").val(ServerId);
							body.find(".ConfigId").val(ConfigId);
							body.find(".GameId").val(2);
							body.find(".SiteId").val(0);
						},
                        cancel:function () {
                            window.history.back();
                        }
					});
				},function(){
				});
			}
            return false;
        	});
        
        //监听选项卡切换
        element.on('tab(Fish_tabs)',function(data){
        	document.getElementById('Fish_Tabindex').value = data.index + 1;
        	table.reload('Alltable2',{
                page : {cuur : 1},
                where:{ConfigId:$('#Fish_Tabindex').val()}
              });
        	table.reload('AllTable', {
          		where: {
          			Room : $('#Fish_Tabindex').val() == 1?"水浒传-房间1":$('#Fish_Tabindex').val() == 2?"水浒传-房间2":"水浒传-房间3",
					Businessman : 0
				}
          	});
              return false;
        });
        

        });
    </script>
	<script type="text/html" id="tool">
        <a class="layui-btn layui-btn-xs" lay-event="pump">抽放水</a>
    </script>
    
    <script type="text/html" id="tool2">
        <a class="layui-btn layui-btn-xs" lay-event="edit">调整</a>
    </script>
</body>
</html>